package task

import "io"

type TaskBase struct {
	key        string
	retryTimes int
	reader     io.Reader
	url        string
	e          error
	result     interface{}
}

func (b *TaskBase) Reader() io.Reader {
	return b.reader
}
func (b *TaskBase) SetReader(r io.Reader) {
	b.reader = r
}

func (b *TaskBase) RetryAble() bool {
	if b.retryTimes > 0 {
		b.retryTimes--
		return true
	} else {
		return false
	}
}

func (b *TaskBase) URL() string {
	return b.url
}

func (b *TaskBase) GetParseFunc(r io.Reader) interface{} {
	return ""
}
func (b *TaskBase) GetKey() string {
	return b.key
}
func (b *TaskBase) SetKey(key string) {
	b.key = key
}
func (b *TaskBase) Error() string {
	return b.e.Error()
}
func (b *TaskBase) SetErr(err error) {
	b.e = err
}

func (b *TaskBase) OccurErr() bool {
	return b.e != nil
}

func (b *TaskBase) SetResult(s interface{}) {
	b.result = s
}
func (b *TaskBase) GetResult() interface{} {
	return b.result
}
